from optparse import OptionParser
import sys

from khronos.gtk.boilerplate import *

parser = OptionParser(description="Utility for showing glade ui files", 
                      usage="%prog [options]", version="%prog 0.0.1a")
parser.add_option("-f", "--file", dest="filename", type="string", 
                  help="specify the xml file containing the user interface")
parser.add_option("-w", "--window", dest="window", type="string", default="window1", 
                  help="specify the name of the window that should be displayed")
options, args = parser.parse_args(sys.argv)

if options.filename is None:
    if len(args) == 1:
        parser.print_help()
        sys.exit(0)
    options.filename = args[1]
b = Builder()
b.add_from_file(options.filename)
w = b.get_object(options.window)
w.connect("destroy", lambda _: gtk.main_quit())
w.show_all()
gtk.main()
